package com.heima.freemarker.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @author itheima
 * @since 2022-07-04
 */
@Controller
public class HelloController {

    @GetMapping("/hello")
    public String hello(Model model) {
        //1,纯文本形式的参数
        model.addAttribute("name","heima");
        //2,实体类相关参数
        Map<String, Object> stu1 =new HashMap<>();
        stu1.put("name","张三");
        stu1.put("age",18);
        model.addAttribute("stu",stu1);

        Map<String, Object> stu2 =new HashMap<>();
        stu2.put("name","itheima");
        stu2.put("age",23);

        //新增集合
        List<Map<String, Object>> list =new ArrayList<>();
        list.add(stu1);
        list.add(stu2);
        model.addAttribute("stus",list);
        model.addAttribute("today",new Date());
        return "01-basic";
    }

}
